home *** CD-ROM | disk | FTP | other *** search
/ Canadian Forces: Canada's NAVY / CF_FS_Navy.iso / pc / data / 0_04_en.dxr / 00003_Volume slider.ls < prev    next >
Encoding:
Text File  |  2005-06-08  |  3.9 KB  |  109 lines

  1. property pMaxVolume, pVolume, videoSprite, extentSprite, hiliteMember, tracking, newLocH, newLocV, dynamic, min, max, valrange, minScreen, maxScreen, currentScreenVal, extentlength, CurrentVal
  2.  
  3. on getPropertyDescriptionList
  4.   if the currentSpriteNum = 0 then
  5.     memdefault = 0
  6.   else
  7.     memref = sprite(the currentSpriteNum).member
  8.     memdefault = member(member(memref).memberNum + 1)
  9.   end if
  10.   description = [:]
  11.   addProp(description, #videoSprite, [#default: 1, #format: #integer, #comment: "Video Sprite:"])
  12.   addProp(description, #extentSprite, [#default: 1, #format: #integer, #comment: "Extent Sprite:"])
  13.   addProp(description, #hiliteMember, [#default: memdefault, #format: #graphic, #comment: "Hilite Member:"])
  14.   addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
  15.   return description
  16. end
  17.  
  18. on getBehaviorDescription
  19.   return "Drag to slider 'handle' to enable control of video volume.  Requires additional 'extent' member which limits the handle travel range." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Video Sprite - Enter the number of sprite channel in which video is displayed." & RETURN & "ΓÇó Extent Sprite -  Enter the number of sprite channel that contains the 'extent' sprite." & RETURN & "ΓÇó Hilite Member -  Member to display while handle is being dragged." & RETURN & "ΓÇó Dynamic - If set, video time will be updated while handle is dragged, else when handle is released."
  20. end
  21.  
  22. on compute_val me
  23.   val = 0.0
  24.   val = float(me.currentScreenVal) / float(me.extentlength)
  25.   val = val * me.valrange
  26.   val = val + me.min
  27.   return val
  28. end
  29.  
  30. on send_the_val me, val
  31.   pVolume = val * pMaxVolume
  32.   sprite(videoSprite).volume = pVolume
  33. end
  34.  
  35. on beginSprite me
  36.   pMaxVolume = 255
  37.   me.min = 0.0
  38.   me.max = 1.0
  39.   handle = me.spriteNum
  40.   me.tracking = 0
  41.   me.newLocH = the locH of sprite handle
  42.   me.newLocV = the locV of sprite handle
  43.   me.newLocV = the locV of sprite me.extentSprite
  44.   me.minScreen = the left of sprite me.extentSprite
  45.   me.maxScreen = the right of sprite me.extentSprite
  46.   set the locH of sprite handle to me.newLocH
  47.   set the locV of sprite handle to me.newLocV
  48.   me.valrange = me.max - me.min
  49.   me.extentlength = me.maxScreen - me.minScreen
  50. end
  51.  
  52. on prepareFrame me
  53.   if tracking then
  54.     handle = me.spriteNum
  55.     extent = me.extentSprite
  56.     me.newLocH = the mouseH
  57.     me.newLocV = the locV of sprite extent
  58.     if me.newLocH < the left of sprite extent then
  59.       me.newLocH = the left of sprite extent
  60.     end if
  61.     if me.newLocH > the right of sprite extent then
  62.       me.newLocH = the right of sprite extent
  63.     end if
  64.     me.currentScreenVal = me.newLocH - me.minScreen
  65.     set the locH of sprite handle to me.newLocH
  66.     set the locV of sprite handle to me.newLocV
  67.     if me.dynamic then
  68.       send_the_val(me, compute_val(me))
  69.     end if
  70.   else
  71.     x = float(sprite(videoSprite).volume) / float(pMaxVolume)
  72.     handle = me.spriteNum
  73.     extent = me.extentSprite
  74.     ScreenX = the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
  75.     me.newLocH = ScreenX
  76.     me.newLocV = the locV of sprite extent
  77.     if me.newLocH < the left of sprite extent then
  78.       me.newLocH = the left of sprite extent
  79.     end if
  80.     if me.newLocH > the right of sprite extent then
  81.       me.newLocH = the right of sprite extent
  82.     end if
  83.     me.currentScreenVal = me.newLocH - me.minScreen
  84.     set the locH of sprite handle to me.newLocH
  85.     set the locV of sprite handle to me.newLocV
  86.   end if
  87. end
  88.  
  89. on mouseDown me
  90.   tracking = 1
  91.   temp = the member of sprite me.spriteNum
  92.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  93.   me.hiliteMember = temp
  94. end
  95.  
  96. on mouseUp me
  97.   tracking = 0
  98.   temp = the member of sprite me.spriteNum
  99.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  100.   me.hiliteMember = temp
  101. end
  102.  
  103. on mouseUpOutSide me
  104.   tracking = 0
  105.   temp = the member of sprite me.spriteNum
  106.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  107.   me.hiliteMember = temp
  108. end
  109.